﻿namespace LearnDSRecursions;

/// <summary>
/// 求阶乘
/// </summary>
public class Factorial
{
    public int Factorialiterative(int n)
    {
        int fact = 1;
        for (int i = 1; i <= n; i++)
        {
            fact = fact * i;
        }

        return fact;
    }

    public int FactorialRecursion(int n)
    {
        if (n == 0)
            return 1;
        return FactorialRecursion(n - 1) * n;
    }
}